using GTA;
using System;
using System.IO;
using System.Windows.Forms;
using GTA.Native;
using GTA.Math;

public class MaskAlwaysOn : Script
{
    private Prop mask;
    private bool maskOn = false;
    public MaskAlwaysOn()
    {
        KeyUp += OnKeyUp;
    }

    void OnKeyUp(object sender, KeyEventArgs e)
    {
        Ped playerPed = Game.Player.Character;
        if (e.KeyCode == Keys.NumPad9)
        {
            if (maskOn)
            {
                if (mask != null)
                {
                    mask.Detach();
                    mask.Delete();
                }
                maskOn = false;
            }
            else
            {
                mask = World.CreateProp(new Model("prop_mp_repair_01"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.FACIAL_facialRoot.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;
                mask = World.CreateProp(new Model("prop_proxy_hat_01"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_Spine3.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;
                
                mask = World.CreateProp(new Model("prop_mp_repair"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_Spine_Root.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_mp_rocket_01"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_R_UpperArm.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_mp_respawn_02"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_R_Forearm.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_mp_spike_01"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_L_UpperArm.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_target_comp_metal"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_L_Forearm.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_target_comp_wood"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_R_Thigh.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_mp_boost_01"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_L_Thigh.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_mp_cant_place_lrg"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_L_Calf.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;

                mask = World.CreateProp(new Model("prop_mp_cant_place_med"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.SKEL_R_Calf.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;
            }
        }
    }
}

